package com.schoolcloud.social.controller.forum;

import com.schoolcloud.common.model.R;
import com.schoolcloud.common.util.UserContext;
import com.schoolcloud.social.entity.SocBardFollow;
import com.schoolcloud.social.service.PostInteractionService;
import com.schoolcloud.social.service.SocBardFollowService;
import com.schoolcloud.social.service.UserForumProfilesService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/social/bard/follow")
@RequiredArgsConstructor
public class SocBardFollowController {
    private final SocBardFollowService socBardFollowService;
    private final PostInteractionService postInteractionService;

    @PostMapping
    public R addFollow(@RequestBody SocBardFollow socBardFollow) {
        socBardFollow.setUserId(Integer.valueOf(UserContext.getUser()));
        postInteractionService.followBard(socBardFollow);
        return R.ok().setMsg("关注成功");
    }
    @DeleteMapping("/{bardId}")
    public R deleteFollow(@PathVariable String bardId) {
        SocBardFollow socBardFollow = new SocBardFollow();
        socBardFollow.setBardId(Integer.valueOf(bardId));
        socBardFollow.setUserId(Integer.valueOf(UserContext.getUser()));
        postInteractionService.deleteFollow(socBardFollow);
        return R.ok().setMsg("取消关注成功");
    }
}
